var ydjs={
	converChinese:function(v,co){
		
		$.ajax({
     	      url: sys_context+"/cssy/base/converChinese.do",
     	      global: false,
     	      type: "POST",
     	      dataType: "text",
     	      data: ({pvalue : v}),		     
     	      success: function(lg){
     	    	  
     	    	 $("#"+co).val(lg);    	
     	      }
     	   }
     	);
	}
};

//添加
function add(){
	var url = basic_WUrl+"/operate/add/0.do";
	
	ShowIframeDialog("operate",basic_Title,url,show_Width,show_Hight);
}
//编辑
function edit(data){
	var url = basic_WUrl+"/operate/edit/"+data.id+".do";
	ShowIframeDialog("operate",basic_Title,url,show_Width,show_Hight);
}

function del(isDelete){
	var manager = $("#table1").ligerGetGridManager(); 
	var rows = manager.getCheckedRows(); 
	
	if (rows.length==0){
		$.dialog.alert('请选择需要删除的行！');
		return;
	}
    
    var ids = "";
	for(var i = 0;i < rows.length ;i ++) {
	 	if(i!=0){
	 		ids+=",";
	 	}
	 	//获得行数据
	 	ids += rows[i].id;					 	   
	}
	
	getDG().dialog({content: "请确定选择删除数据(Yes或者No)!",width: 250,lock: true,max: false,min: false,
		title:'Confirm Infor',
		button: [
		         {
		             name: 'Yes',
		             callback: function(){
			            $.ajax({
			           	      url: basic_Url+"/delete.do",
			           	      global: false,
			           	      type: "POST",
			           	      dataType: "json",
			           	      data: ({ids : ids,isDelete:isDelete}),		     
			           	      success: function(msg){	
			           	    	manager.removeRange(rows);
			           	    	  $.dialog.alert(msg.infor);  		    	
			           	      }
			           	   }
			           	);
		             }
		         },
		         {
		        	   name: 'No',
			           focus: true
		         }             
		     ]
	}).zindex();
	
}

function searchHubWindow(codename,codeid, hbid,hei , wid) {
	hei = hei || 400;
	wid = wid || 800;
	getDG().dialog({
		title:'选择库位位置',
		width : wid,
		height : hei,
		content: 'url:' + sys_context+'/cjmy/logic/common/manager.do',//
		lock : true,
		max : true,
		min : true,
		ok: function(){
			var getSelectedHub=this.content.getSelectedHub();
			if (getSelectedHub != null) {
				$("#"+codeid).val(getSelectedHub.pcode);
				$("#"+codename).val(getSelectedHub.whname + getSelectedHub.flname + getSelectedHub.arcode);
				$("#"+hbid).val(getSelectedHub.id);
				 return true;
			}
    		return false;
			
	    },
	    cancelVal: '关闭',
	    cancel: true 
	}).zindex();
}
function searchCompanyWindow(codeid, hbid,hei , wid) {
	hei = hei || 350;
	wid = wid || 650;
	getDG().dialog({
		title:'选择客户',
		width : wid,
		height : hei,
		content: 'url:' + sys_context+'/cjmy/logic/common/SeachCompany.do',//
		lock : true,
		max : true,
		min : true,
		ok: function(){
			var getSelectedHub=this.content.getSelected();
			if (getSelectedHub != null) {
				$("#"+codeid).val(getSelectedHub.pname);
				$("#"+hbid).val(getSelectedHub.pcode);
				 return true;
			}
    		return false;
			
	    },
	    cancelVal: '关闭',
	    cancel: true 
	}).zindex();
}

//查询物料
function searchItemWindow() {
	getDG().dialog({
		title:'选择材料',
		width : 650,
		height : 350,
		content: 'url:' + sys_context+'/public/windowalert/itemmanager.do',//
		lock : true,
		max : true,
		min : true,
		ok: function(){
			var getSelectedHub=this.content.getSelected();
			if (getSelectedHub != null) {
					
				 return true;
			}
    		return false;
			
	    },
	    cancelVal: '关闭',
	    cancel: true 
	}).zindex();
}

///////////////////////////////////////////////

/**
 * 表单控件禁用
 * @param bTrue true 禁用，false不禁用
 * @author huang.xuming [2013-08-22]
 */
function formComponentDisabled(bTrue){
	$("input[type!='hidden']").attr("disabled",bTrue);//禁用SELECT标签
	$("select").attr("disabled",bTrue);//禁用SELECT标签
	$("textarea").attr("disabled",bTrue);//禁用TEXTAREA标签
}

//附件查看
function uploadFileWindow(zdId,zdType){
	var saleId = $("#"+zdId).val();
	if(saleId==null||saleId==''||saleId==undefined){
		if('plan'==zdType){
			$.dialog.alert("请选选择要做计划的销售订单");
		}
		if('diaodu'==zdType){
			$.dialog.alert("请选选择要做调度的计划单");
		}
		if('paigong'==zdType){
			$.dialog.alert("请选选择要做派工的单据");
		}
		return false;
	}
	getDG().dialog({
		title : '附件查看',
		width : 650,
		height : 350,
		content : 'url:' + sys_context+ '/public/windowalert/uploadFile.do?saleId='+saleId,    
		lock : true,
		max : true,
		min : true,
		cancelVal : '关闭',
		cancel : true
	}).zindex();
}